package com.chl.xadmin.common.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String message;
    private T data;


    public static<T> Result<T> success() {
        return new Result<T>(ResultCode.SUCCESS, "success", null);
    }

    public static<T> Result<T> success(T data) {
        return new Result<T>(ResultCode.SUCCESS, "success", data);
    }

    public static<T> Result<T> success(T data, String message) {
        return new Result<T>(ResultCode.SUCCESS, message, data);
    }

    public static<T> Result<T> success(String message) {
        return new Result<T>(ResultCode.SUCCESS, message, null);
    }

    public static<T>  Result<T> error(){
        return new Result<>(ResultCode.ERROR,"error",null);
    }

    public static<T>  Result<T> error(Integer code){
        return new Result<>(code,"error",null);
    }

    public static<T>  Result<T> error(Integer code, String message){
        return new Result<>(code,message,null);
    }

    public static<T>  Result<T> error( String message){
        return new Result<>(ResultCode.ERROR, message,null);
    }
}
